fix(git): pick the credential for the transport the remote actually uses - #270
Merged
viniciussanchez merged 2 commits intoAug 3, 2026
Merged
Conversation
The Lint job was already red when HashLoad#268 merged, on two findings from that PR: setup/migrations.go:59: cognitive complexity 25 of func `seven` (gocognit) pkg/env/legacy_auth_test.go:76: declaration of "err" shadows line 70 (govet) `seven` grew past the threshold because the rewrite dropped the //nolint the original carried. Rather than put the suppression back, the per-entry work moves into migrateLegacyAuth and the decrypt-or-warn step into decryptLegacy, which reads better than the three near-identical blocks it replaces and takes the complexity down on its own. No behaviour change: `go test ./...` stays green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The credential is looked up by host prefix, but the transport comes from the URL the repository fetches from. Those disagree whenever a cache was cloned over HTTPS before an SSH login was configured for that host: dep.GetURL() returns the SSH form once auth.UseSSH is set, while the cached remote stays HTTPS. go-git v5.4.2 ignored an SSH credential handed to the HTTP transport and fetched anonymously. Since the upgrade to v5.19.1 it returns transport.ErrInvalidAuthMethod instead, so every fetch for that host fails -- and because a failed fetch only warned, Boss still reported "Installation completed successfully" and exited 0. The project silently stayed on whatever the cache last held. Measured against v3.0.12 on the same cache, same auth and same project, with a cache missing the newest tag of hashload/cqlbr: without this change: 4x "invalid auth method", cache untouched, cqlbr 1.1.6 with this change: no warning, tag restored, cqlbr 1.1.51 (v3.0.12 parity) GetAuthForURL resolves the credential against the effective remote URL and returns nil when it does not fit the transport, which restores the anonymous fetch go-git used to perform on its own. A private repository reached over the wrong transport still fails, exactly as it did before. The fetch failure in UpdateCacheEmbedded was logged at debug level, so it was invisible at normal verbosity. It now warns and says the cached copy is being used, which is the difference between "up to date" and "whatever was cached". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
8 tasks
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
=======================================
Coverage ? 28.54%
=======================================
Files ? 90
Lines ? 5700
Branches ? 0
=======================================
Hits ? 1627
Misses ? 3933
Partials ? 140
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Validado antes de subir: PR de validação no fork com os 6 checks verdes, lint incluído.
O problema
Com qualquer auth SSH cadastrada para um host (
boss login <host> -s), todo fetch de dependência daquele host falha — e o Boss reporta sucesso mesmo assim:Exit 0. O projeto fica congelado na versão que já estava em cache, em silêncio. Em CI isso passa verde.
Causa
A credencial é buscada pelo prefixo do host, mas o transporte vem da URL que o repositório realmente busca. Os dois discordam sempre que um cache foi clonado por HTTPS antes de uma auth SSH existir para aquele host:
dep.GetURL()passa a devolver a forma SSH assim queauth.UseSSHestá setado, enquanto o remote em cache continua HTTPS.O go-git
v5.4.2ignorava uma credencial SSH entregue ao transporte HTTP e buscava anonimamente. Desde o bump parav5.19.1ele devolvetransport.ErrInvalidAuthMethod. A construção de URL do Boss é idêntica entre v3.0.12 (models/dep.go:47-56) e hoje (internal/core/domain/dependency.go:65-84) — o que mudou foi a dependência.A correção
Configuration.GetAuthForURL(repo, rawURL)resolve a credencial contra a URL efetiva e devolvenilquando ela não serve ao transporte, restaurando o fetch anônimo que o go-git fazia sozinho. Repositório privado alcançado pelo transporte errado continua falhando, exatamente como antes.Os cinco call sites passaram a informar a URL real:
dep.GetURL()remoteURL()O erro de fetch em
UpdateCacheEmbeddedestava emmsg.Debug— invisível em verbosidade normal. Viroumsg.Warndizendo que a cópia em cache está sendo usada.Medição
Mesmo cache, mesma auth SSH, mesmo projeto (
HashLoad/ormbr), semboss-lock.json, com o cache faltando a tag mais nova dohashload/cqlbr. Só troca o binário:invalid auth methodO
1.1.6é o dano concreto. Paridade com o v3.0.12 conferida no mesmo snapshot de cache — os quatro módulos resolvem idêntico:Testes
go test ./...verde nos 29 pacotes. Seis testes novos empkg/env/auth_transport_test.go:nilgit@host:path,ssh://,https://,http://ehttps://user@host/path, que não pode ser confundido com sintaxe scpA chave ed25519 é gerada e cifrada em tempo de execução, então o teste não depende de chave no ambiente.
Independência
Verificado com
git merge-tree:fix/auth-transport-mismatch→main: limpofix/legacy-auth-and-version→main: limpoOs dois fixes também foram mesclados localmente para o teste E2E, sem conflito. Podem ser mergeados em qualquer ordem.
Fora de escopo
Falha de fetch continua não alterando o exit code. Endurecer isso muda a política para quem trabalha offline ou atrás de rede instável, e não é o que este bug exige — com o fix, o
invalid auth methoddeixa de acontecer. Se quisermos endurecer mesmo, vale discutir separado, porque afeta CI de terceiros.🤖 Generated with Claude Code